<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" >
<head>
	<link th:replace="fragment/common_edit_header" />
	<title>修改密码</title>
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content ">
		<div class="row">
			<form role="form" id="form" method="post">
				<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
					<div class="form-group">
						<label for="password">新密码<em>*</em></label>
						<input class="form-control input-sm" type="password" name="password" id="password" />
					</div>
				</div>
			</form>
		</div>
	</div>
	
	<!-- 底部按钮 -->
	<div class="form-group col-xs-12" style="height:40px;"></div>
	<div class="div-footer">
		  <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" align="center">
		     <button type="submit" class="btn btn-primary btn-sm" id="b-btn-save">
		        <i class="fa fa-save"></i>
		        &nbsp;&nbsp;&nbsp;保存&nbsp;&nbsp;&nbsp;
		     </button>
		        &nbsp;&nbsp;&nbsp;
		     <button type="button" class="btn btn-default btn-sm" id="cancel-but">
		        <i class="fa fa-close"></i>
		         &nbsp;&nbsp;&nbsp;取消&nbsp;&nbsp;&nbsp;
		     </button>
		 </div>
	</div>

<script th:replace="fragment/common_edit_js"></script>
<script type="text/javascript">

$(function () {
	
	$('#form').validate({
		rules:{
			password: {
				required:true
			}
		},
		messages:{
			password: {
				required: '请填写新密码'
			}
		},
	    submitHandler:function(form){
	    	
	    	updatePassword();
	    	
	    	return false;
	    }
	});
	
	function updatePassword() {
		
		var parentLayer = window.parent.layer;
		
		var data = $('#form').serializeJson();
		
		$.request({
			type: 'post',
			url: '/password/update',
			data: JSON.stringify(data),
			success: function(result) {
				var index = parentLayer.getFrameIndex(window.name);
				parentLayer.close(index);
				if(result.code == '0') {
					parentLayer.alert('密码修改成功', {icon: 1});
				} else {
					parentLayer.alert(result.msg, {icon: 5});
				}
			}
		});
		
		
	}
	
});

</script>
</body>
</html>
